package bark.sihu.task;

import lombok.Getter;
import lombok.Setter;
import org.hq.sihu.ItaskService;
import org.hq.sihu.SihuWebPojo;
import org.hq.sihu.UpdataService;
import org.hq.upvideo.EupVideoTaskType;
import org.hq.tool.GetSpringBean;
import org.springframework.beans.BeanUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 四虎视频网站数据实体类
 * 用于任务业务逻辑抽象类
 */

public abstract class WebPojoTask extends SihuWebPojo implements Runnable {
    //服务更新
    protected final ItaskService ups = GetSpringBean.getBean(UpdataService.class);
    @Setter
    @Getter
    protected EupVideoTaskType eupVideoTaskType;//任务类型
    @Setter
    @Getter
    protected String taskPath;//任务路径用于存储任务路径

    public WebPojoTask(WebPojoTask obj) {
        //数据拷贝
        this.copyTask(obj);
    }

    /**
     * 对象任务拷贝
     *
     * @param obj 数据源
     */
    public final void copyTask(WebPojoTask obj) {
        if (obj == null) {
            return;
        }
        //数据拷贝
        BeanUtils.copyProperties(obj, this);

    }
    /**
     * 模拟 qq 浏览器请求头
     *
     * @return 返回请求头
     */
    protected final Map<String, String> getRequestHeaders() {
        Map<String, String> headers = new HashMap<>();
        headers.put("Sec-Ch-Ua", "Not)A;Brand;v=24, Chromium;v=116");
        headers.put("Sec-Ch-Ua-Mobile", "?0");
        headers.put("Sec-Ch-Ua-Platform", "Windows");
        headers.put("Sec-Fetch-Dest", "document");
        headers.put("Sec-Fetch-Mode", "navigate");
        headers.put("Sec-Fetch-Site", "same-origin");
        headers.put("Sec-Fetch-User", "?1");
        headers.put("Upgrade-Insecure-Requests", "1");
        String useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.97 Safari/537.36 Core/1.116.438.400 QQBrowser/13.0.6071.400";
        headers.put("user-agent", useragent);
        return headers;
    }
}
